﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="HomePage.aspx.vb" Inherits="CW1.HomePage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <p>
        &nbsp;<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate> 
                <br />               
                <font size="20px" color="blue"><%# Eval("FirstName")%> <%#Eval("LastName")%><br /></font>
                <p class="portrait">
                <img src="/<%#Eval("Portrait") %>"  height="64px" width="85px"/><br />
                Date of Birth: <%# getDate(Eval("DateOfBirth"))%><br />
                Gender: <%#Eval("Gender")%><br />
                Registration Date: <%# getDate(Eval("RegistrationDate")) %></p>                
            </ItemTemplate>


        </asp:Repeater>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:WarriorConnection %>" 
            ProviderName="<%$ ConnectionStrings:WarriorConnection.ProviderName %>" 
            SelectCommand="SELECT [DinerId], [FirstName], [LastName], [Portrait], [DateOfBirth], [RegistrationDate], [Gender] FROM [UserProfile] WHERE ([DinerId] = ?)">
            <SelectParameters>
                <asp:QueryStringParameter Name="DinerId" QueryStringField="UserName" 
                    Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        <p class="addContentTitle">Uploaded Articles</p>
        <hr />
    <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource2">
        <ItemTemplate>           
            <a href="Article.aspx?UserName=<%=User.Identity.Name %>&Title=<%#Eval("Title") %>"><p><font size="x-large"><%#Eval("Title") %></font></p></a>
        </ItemTemplate>
    </asp:Repeater>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:WarriorConnection %>" 
        ProviderName="<%$ ConnectionStrings:WarriorConnection.ProviderName %>" 
        SelectCommand="SELECT [ID], [UserName], [Title], [Body] FROM [Article] WHERE ([UserName] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="UserName" QueryStringField="UserName" 
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <p>
        <asp:Button ID="btn_addArticle" runat="server" BackColor="#660066" 
            BorderStyle="None" CssClass="addContentButton" Font-Size="Small" 
            ForeColor="White" Text="Add New Article" />
    </p>
    <br /><br />
    <p class="addContentTitle">
        Uploaded Pictures</p>
    <hr />
    <asp:Repeater ID="Repeater3" runat="server" DataSourceID="SqlDataSource3">
        <ItemTemplate>
            <img src="<%#Eval("PictureURL") %>"/>
        </ItemTemplate>
    </asp:Repeater>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:WarriorConnection %>" 
        ProviderName="<%$ ConnectionStrings:WarriorConnection.ProviderName %>" 
        SelectCommand="SELECT [ID], [UserName], [PictureURL] FROM [Picture] WHERE ([UserName] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="UserName" QueryStringField="UserName" 
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <p>
        <asp:Button ID="btn_addPicture" runat="server" BackColor="#660066" 
            BorderStyle="None" CssClass="addContentButton" Font-Size="Small" 
            ForeColor="White" Text="Add New Picture" />
    </p>
    <p class="addContentTitle">
        Message Board</p>
    <p>
    <hr />
        <asp:Repeater ID="Repeater4" runat="server" DataSourceID="SqlDataSource4">
            <ItemTemplate>
                <font size="large" color="black">
                <%#Eval("FromUser")%> said:<br />
                <%#Eval("Body")%></font>
                <hr />
            </ItemTemplate>
        </asp:Repeater>
        <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
            ConnectionString="<%$ ConnectionStrings:WarriorConnection %>" 
            ProviderName="<%$ ConnectionStrings:WarriorConnection.ProviderName %>" 
            
        SelectCommand="SELECT [ID], [FromUser], [ToUser], [Body] FROM [Message] WHERE ([ToUser] = ?)">
            <SelectParameters>
                <asp:QueryStringParameter Name="ToUser" QueryStringField="UserName" 
                    Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
    </p>
    <p>
        <asp:Button ID="btn_msg" runat="server" BackColor="#660066" BorderStyle="None" 
            CssClass="addContentButton" ForeColor="White" Text="Leave a message" />
    </p>
    <br />
    <p id="para"></p>
</asp:Content>
